<template>
  <div v-loading="loading" style="width: 100%;height: 100%">
    <lab-process v-if="element.props.callCmd" :element="element" :model-data="modelData" />
    <el-empty v-else description="未知视图" style="height: 100%"></el-empty>
  </div>
</template>

<script>
import LabProcess from "@/components/lab-process/LabProcess";
export default {
  name: "AppView",
  components: {LabProcess },
  provide() {
    return {
      appInfo: this.appInfo
    }
  },
  data() {
    return {
      loading: true,
      element: { elements: [], props: { callCmd: '' } },
      modelData: {},
      appInfo: { appId: '0' },
      quickInfo: {}
    }
  },
  created() {
    this.loading = true
    this.loadQuick()
  },
  methods: {
    loadQuick() {
      const { params, query } = this.$route
      this.$Util.copyAttr(query, this.modelData, null, this)
      const { quickId } = params
      if (!quickId) {
        this.loading = false
        return
      }
      this.$get('/appQuick/loadQuick/' + quickId)
          .then(res => {
            this.$resultMsg(this, res, true)
            this.$Util.cleanObj(this, this.appInfo)
            this.$Util.cleanObj(this, this.quickInfo)
            if (res.code === 200) {
              this.$Util.copyAttr(res.data.appInfo, this.appInfo, null, this)
              this.$Util.copyAttr(res.data, this.quickInfo, null, this)
            }
            const { callView, callProcess } = this.quickInfo
            this.$set(this.element.props, 'callCmd', callView)
            this.$set(this.modelData, 'processDefId', callProcess)
            this.loading = false
          })
    }
  }
}
</script>

<style scoped>

</style>
